package com.example.administrator.animationdemo.view;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import com.example.administrator.animationdemo.R;

public class TipCircleView extends View {

    private Paint paint;
    private boolean isFill;
    private int initX; // 初始中心点X坐标
    private int initY; // 初始中心点Y坐标
    private int currentX; // 当前中心点X坐标
    private int currentY; // 当前中心点Y坐标
    private int initR; // 半径

    public TipCircleView(Context context) {
        super(context);
        init();
    }

    public TipCircleView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        paint = new Paint();
        paint.setAntiAlias(true);
        paint.setColor(getResources().getColor(R.color.color_circle_alpha));
        paint.setStyle(Paint.Style.STROKE);
        isFill = false;
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        if (isFill)
            paint.setStyle(Paint.Style.FILL);
        else
            paint.setStyle(Paint.Style.STROKE);

        int centerX = getWidth() / 2;
        int centerY = getHeight() / 2;
        int radius = centerX <= centerY ? centerX : centerY;
        canvas.drawCircle(centerX, centerY, radius, paint);
    }

    public void setFill(boolean isFill) {
        this.isFill = isFill;
    }

    public int getInitX() {
        return initX;
    }

    public void setInitX(int initX) {
        this.initX = initX;
    }

    public int getInitY() {
        return initY;
    }

    public void setInitY(int initY) {
        this.initY = initY;
    }

    public int getInitR() {
        return initR;
    }

    public int getCurrentX() {
        return currentX;
    }

    public void setCurrentX(int currentX) {
        this.currentX = currentX;
    }

    public int getCurrentY() {
        return currentY;
    }

    public void setCurrentY(int currentY) {
        this.currentY = currentY;
    }

    public void setInitR(int initR) {
        this.initR = initR;
    }
}
